home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.3 KB | 87 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 3277951 18-Feb-90 15:44PST
-
- From: D0416 Futuresoft System Design,PRT
-
- To: D5295 Reseach SW Design, D Goldman,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: RE-Undoable commands
-
- Hi Dave,
-
- Glad to see the Guerrilla effort (The Class Room) off and running. It will
- benefit us all!
-
- RE: My problem is that we're performing a TControlTracker command when my
- >TControl.TrackMouse sees the mouse-up. We need to let
- >TControlTracker.TrackMouse return gNoChanges, and then somehow tell MacApp to
- >perform my new undoable command.
- >(Simply having TrackMouse return myCommand won't work.)
- >
- >Bottom line (simple???) question: how do you get a mouse-tracking command
- >object to create and perform a different command object?
-
- Hmm… maybe this (somewhat hacky) approach will work. I haven’t tried this
- myself so no guarantees:
-
- Add a method (function) to TYourControl class called
- TYourControl.MakeUndoableTracker(…) which instantiates and returns an undoable
- command object. Then in TYourControlTracker.TrackMouse you call
- TYourControl(fControl).MakeUndoableTracker(…) and return the newly created
- undoable command as the TYourControlTracker.TrackMouse result. I believe MacApp
- will take care of undoable activities from that point on.
-
- FUNCTION TYourControl.MakeUndoableTracker(…): TUndoableCommand;
- VAR anUndoableCmd: TUndoableCommand;
-
- BEGIN
- MakeUndoableTracker := NIL; {first assume you won't make one}
- IF the situation warrants one THEN {create a command and return it}
- BEGIN
- NEW(anUndoableCmd); {instantiate it}
- FailNIL(anUndoableCmd);
- anUndoableCmd.IAnUndaobleCommand;
- MakeUndoableTracker := anUndoableCmd; {return it}
- END;
- END;
-
- FUNCTION TYourControlTracker.TrackMouse(aTrackPhase: TrackPhase; VAR
- anchorPoint, previousPoint, nextPoint: VPoint; mouseDidMove: BOOLEAN):
- TCommand; OVERRIDE;
- VAR aCommand: TCommand;
- newCommand: TCommand;
-
- BEGIN
- {call INHERITED to enable default behavior}
- aCommand := INHERITED TrackMouse(aTrackPhase,anchorPoint,…);
- IF aCommand = SELF THEN {command still alive, change to an undoable cmd}
- BEGIN
- {get yourControl to make UNDOABLE command if appropriate}
- newCommand := TYourControl(fControl).MakeUndoableCommand(…);
- IF newCommand <> NIL THEN {we have a new UNDOABLE command}
- aCommand := newCommand; {set up to return it}
- END;
- TrackMouse := aCommand;
- END;
-
- NOTE: the ellipse (“…”) in the the parm areas means fill in as appropriate
-
- MacApp should “see” that you changed the tracker command, free the old command
- and continue calling track methods of the now new UNDOABLE command. You can
- check this out in the MacApp source code. Look at the local procedure TrackOnce
- in the TApplication.TrackMouse procedure. It all finally unwinds to this code.
- WARNING: None of this works for controls subclassed from TCtlMgr since TCtlMgr
- does its stuff via DoChoice method without trackers.
-
- The whole issue of returning commands to MacApp is supposed to be really slick
- and flexible in MA 2.0 final. In the mean time I hope the above approach guides
- you to a solution.
-
- -Ken Addison
-
-
-
-